<template>
  <common-page v-model="height" class="comm-panel-nowrap">
    <template v-slot:header>
      <div class="common-form-control">
        <el-select v-model="queryObj.attr1" placeholder="废气" style="width:120px;">
          <el-option
            v-for="item in list1"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </div>
      <div class="common-form-control">
        <el-select v-model="queryObj.attr2" placeholder="烟尘" style="width:120px;">
          <el-option
            v-for="item in list2"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </div>
      <div class="common-form-control">
        <el-date-picker
          v-model="queryObj.attr3"
          type="daterange"
          format="yyyy-MM-dd"
          value-format="yyyy-MM-dd"
          style="width:240px"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :clearable="false"
        />
      </div>
      <div class="common-form-control">
        <el-select v-model="queryObj.attr4" placeholder="行业" style="width:120px;">
          <el-option
            v-for="item in list4"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </div>
      <div class="common-form-control">
        <el-select v-model="queryObj.attr5" placeholder="化工" style="width:120px;">
          <el-option
            v-for="item in list2"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </div>
    </template>
    <div v-loading="loading">
      <card-panel title="烟尘区域统计" :style="{'height':tableHeight+'px'}">
        <v-chart
          autoresize
          :options="options"
          style="width:100%;height:100px;"
          :style="{'height':tableHeight+'px'}"
        />
      </card-panel>
    </div>
  </common-page>
</template>

<script>
import CommonPage from '@/components/CommonPage/index.vue'
import 'echarts/lib/chart/line'
import 'echarts/lib/chart/bar'
import 'echarts/lib/chart/pie'
import 'echarts/lib/component/tooltip'
import 'echarts/lib/component/legend'

export default {
  name: 'QushiDuibi',
  components: {
    CommonPage
  },
  data() {
    return {
      loading: false,
      height: 600,
      list1: [],
      list2: [],
      list3: [],
      list4: [],
      list5: [],
      queryObj: {
        attr1: '',
        attr2: '',
        attr3: '',
        attr4: '',
        attr5: ''
      }
    }
  },
  computed: {
    tableHeight() {
      return this.height - 50
    },
    options() {
      return {
        color: [
          '#4AA0FF',
          '#7ED321',
          '#50E3C2',
          '#F5A623',
          '#3263A9'
        ],
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          }
        },
        legend: {
          data: ['市辖区', '左权县', '榆次区', '昔阳县', '吾中市经济开发区'],
          bottom: 20,
          icon: 'circle',
          itemWidth: 10,
          itemHeight: 10,
          textStyle: {
            fontSize: 13
          }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '8%',
          containLabel: true
        },
        xAxis: [
          {
            type: 'category',
            data: [
              '2020-12-01',
              '2020-12-02',
              '2020-12-03',
              '2020-12-04',
              '2020-12-05',
              '2020-12-06',
              '2020-12-07',
              '2020-12-08',
              '2020-12-09',
              '2020-12-10'
            ],
            axisLine: {
              show: true,
              lineStyle: {
                color: '#E9ECF1'
              }
            },
            axisLabel: {
              color: '#606266',
              textStyle: {
                fontSize: 13
              }
            },
            splitLine: {
              lineStyle: {
                color: '#e9ecf1'
              }
            }
          }
        ],
        yAxis: [
          {
            type: 'value',
            axisLine: {
              show: true,
              lineStyle: {
                color: '#E9ECF1'
              }
            },
            axisLabel: {
              color: '#606266',
              textStyle: {
                fontSize: 13
              }
            },
            splitLine: {
              lineStyle: {
                color: '#e9ecf1'
              }
            }
          }
        ],
        series: [
          {
            name: '市辖区',
            type: 'bar',
            barWidth: 9,
            itemStyle: {
              normal: {
                barBorderRadius: [4, 4, 0, 0]
              }
            },
            data: [320, 332, 301, 334, 390, 330, 320]
          },
          {
            name: '左权县',
            type: 'bar',
            barWidth: 9,
            itemStyle: {
              normal: {
                barBorderRadius: [4, 4, 0, 0]
              }
            },
            data: [120, 132, 101, 134, 90, 230, 210]
          },
          {
            name: '榆次区',
            type: 'bar',
            barWidth: 9,
            itemStyle: {
              normal: {
                barBorderRadius: [4, 4, 0, 0]
              }
            },
            data: [220, 182, 191, 234, 290, 330, 310]
          },
          {
            name: '昔阳县',
            type: 'bar',
            barWidth: 9,
            itemStyle: {
              normal: {
                barBorderRadius: [4, 4, 0, 0]
              }
            },
            data: [150, 232, 201, 154, 190, 330, 410]
          },
          {
            name: '吾中市经济开发区',
            type: 'bar',
            barWidth: 9,
            itemStyle: {
              normal: {
                barBorderRadius: [4, 4, 0, 0]
              }
            },
            data: [862, 1018, 964, 1026, 1679, 1600, 1570]
          },
        ]
      }
    }
  },
  methods: {
    page({ pageNo }) {
      if (pageNo != undefined) {
        this.queryParams.pageNo = pageNo
      }
      this.fetchList()
    },
    fetchList() {
      this.loading = true
      new Promise((resolve, reject) => {
        this.loading = false
        resolve()
      })
    }
  }
}
</script>

<style scoped>

</style>
